/**
* File: search.h
*
* \brief Pathfinding structures and algorithms.
*
* \author Instituto Superior Tecnico de Lisboa, Portugal
* \author Technical University of Lisbon, Portugal
* 
* \author Agentes Autonomos e Sistemas Multiagente
* \author Autonomous Agents and Multiagent Systems
* 
* \version	1.0
* \date		2006/2007
**/
#pragma once

namespace game { namespace search {
	//=============================================================================
	// Enumerations
	//=============================================================================
	enum AStarState {OPEN, CLOSED, NEW};

	//=============================================================================
	// Structures
	//=============================================================================
	/** A* algorithm node **/
	struct AStarList
	{
		double g;
		double f;
		short iParentIndex;
		AStarState iState;
	}; 


	/* Links waypoints returned from search algorithms */
	typedef struct pathnode
	{
		int iIndex;
		pathnode *NextNode;
	} PathNode;

	//=============================================================================
	// Global variables
	//=============================================================================
	/** Floyd-Warshall shortest distance algorithm distance matrix **/
	extern int *g_pFloydDistanceMatrix; 
	/** Floyd-Warshall shortest distance algorithm path matrix **/
	extern int *g_pFloydPathMatrix;

	//=============================================================================
	// Function prototypes
	//=============================================================================
	void initializeFloydWarshallMatrices();
	PathNode* aStar(
		int startIndex, int endIndex, 
		float (*costFunction)(int, int), 
		float (*heuristicFunction)(int, int, int));
	PathNode* floydWarshallShortestPath(int startIndex, int endIndex);

	float costFunctionPathDistance(int iThisIndex, int iParent);
	float costFunctionPathDistanceAvoidNoHostage(int iThisIndex, int iParent);
	float heuristicFunctionPathDistance(int iIndex, int iStartIndex, int iGoalIndex);
}}